//package com.hikvision.cms;
//
//import org.apache.activemq.ActiveMQConnectionFactory;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import javax.jms.*;
//
//
//public class BaseMQService {
//    private static final Logger log = LoggerFactory.getLogger(com.hikvision.cms.BaseMQService.class);
//
//
//    public static final String BROKER_URL = "failover:(tcp://183.136.185.7:61616)?timeout=2000";
//
//
//    protected void assertNotNull(Destination destination) {
//        if (destination == null) {
//            throw new NullPointerException("Destination should not be null!");
//        }
//    }
//
//
//    protected void sendUnSerializeMessage(Destination destination, Message message) {
//        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("failover:(tcp://183.136.185.7:61616)?timeout=2000");
//        Connection connection = null;
//        Session session = null;
//        MessageProducer publisher = null;
//        try {
//            connection = factory.createConnection();
//            connection.start();
//            session = connection.createSession(false, 1);
//            publisher = session.createProducer(destination);
//
//            publisher.setDeliveryMode(2);
//            publisher.send(message);
//        } catch (JMSException e) {
//            e.printStackTrace();
//            log.info(e.getMessage());
//        } finally {
//            close(session, connection);
//        }
//    }
//
//    protected void close(Session session, Connection connection) {
//        close(session);
//        close(connection);
//    }
//
//    protected void close(Connection connection) {
//        try {
//            if (connection != null) {
//                connection.stop();
//                connection.close();
//            }
//        } catch (JMSException e) {
//            e.printStackTrace();
//            log.info(e.getMessage());
//        }
//    }
//
//    protected void close(Session session) {
//        try {
//            if (session != null) {
//                session.close();
//            }
//        } catch (JMSException e) {
//            e.printStackTrace();
//            log.info(e.getMessage());
//        }
//    }
//}
//
